import easygui as g
import os
dir1=g.diropenbox()
list1=list(os.walk(dir1))
count=0
count1=0
list2=[]
for wd in range(len(list1)):
    for line in list1[wd][2]:
        flag=os.path.splitext(line)
        if flag[1] == '.py':
            print('正在分析文件:%s'%line)
            list2.append(line)
            count1 +=1
            with open(line,'r',encoding='utf-8') as f1:
                f1.seek(0,0)
                for i in f1:
                    if i != '': 
                        count+=1
'list1=[]'
进度 = str(count/1000)+'%'
剩余 = 100000-count
内容 = '【.py】文件共%d个，代码%d行' %(count1,count)
msg = '您目前共累积编写了%d行代码，完成进度%s\n离10万行代码\
还差%d行，请继续努力'% (count,进度,剩余)
g.textbox(msg,'统计结果',内容)
